<script setup lang="ts">
import { reLaunch, getCurrentInstance } from '@tarojs/taro';
import RepairEdit from './components/repair-edit.vue';
import { onMounted, onBeforeUnmount } from 'vue';
import { state } from '../../submit-success/state';
onMounted(() => (state.from = 'repair-edit-single'));
onBeforeUnmount(() => (state.from = ''));
/**
 * @description 当前路由信息
 */
const params = getCurrentInstance().router?.params as unknown as {
  templateCode: string;
};
</script>

<template>
  <view class="repair-edit-single app-page--1">
    <app-navbar title="报事报修" />
    <nut-tabs
      class="repair-edit-single__nut-tabs"
      model-value="edit"
      @click="
        ({ paneKey }) => {
          if (paneKey === 'record') {
            reLaunch({
              url: `/pages/approve/record/index?from=repair_single&templateCode=${params.templateCode}`,
            });
          }
        }
      "
    >
      <nut-tab-pane title="发起申请" pane-key="edit" />
      <nut-tab-pane title="申请记录" pane-key="record" />
    </nut-tabs>
    <repair-edit />
  </view>
</template>
<style lang="scss">
.repair-edit-single {
  .nut-tabs {
    &__content {
      display: none;
    }
  }
}
</style>
